package com.tourismhengyang.actions;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.tourismhengyang.beans.AgencyInfo;
import com.tourismhengyang.biz.IAgencyInfoBiz;
import com.tourismhengyang.impl.AgencyInfoBizImpl;
import com.tourismhengyang.utils.JsonObject;

public class AgencyInfoAction extends ActionSupport implements ModelDriven<AgencyInfo>{

	private static final long serialVersionUID = 1L;
	private JsonObject json;
	private AgencyInfo ai;
	private IAgencyInfoBiz agencyInfoBiz=new AgencyInfoBizImpl();
	public String getAgencyInfoList(){
		List<AgencyInfo> list=agencyInfoBiz.getAgencyInfoList();
		if(list!=null){
			json=new JsonObject();
			json.setRows(list);
			json.setTotal(list.size());
			return SUCCESS;
		}
		return null;
	}
	
	public String addAgencyInfo(){
		int result=agencyInfoBiz.addAgencyInfo(ai);
		json=new JsonObject();
		json.setObj(result);
		return SUCCESS;
	}
	
	public JsonObject getJson() {
		return json;
	}

	@Override
	public AgencyInfo getModel() {
		if(ai==null){
			ai=new AgencyInfo();
		}
		return ai;
	}
}
